/*
 * ClassOptions_Beans.java
 *
 * Created on December 8, 2008, 2:20 AM
 */

package gui.beans;

import javax.swing.DefaultListModel;
import javax.swing.JPopupMenu;

/**
 * 
 * @author Jason
 */
public abstract class ClassOptions_Beans extends javax.swing.JPanel {

	protected final DefaultListModel methodModel = new DefaultListModel();
	protected final DefaultListModel fieldModel = new DefaultListModel();

	/** Creates new form ClassOptions_Beans */
	public ClassOptions_Beans() {
		initComponents();
	}

	protected abstract JPopupMenu getMethodPopupMenu();

	protected abstract JPopupMenu getFieldPopupMenu();

	protected abstract void updateClassName(String name);

	protected abstract void updateParent(String name);

	protected abstract void updatePackage(String name);

	protected abstract void addMethod(String txt);

	protected abstract void addField(String txt);

	protected abstract void setAbstract(boolean b);

	/**
	 * This method is called from within the constructor to initialize the form.
	 * WARNING: Do NOT modify this code. The content of this method is always
	 * regenerated by the Form Editor.
	 */
	// <editor-fold defaultstate="collapsed" desc="Generated Code">
	private void initComponents() {

		jLabel1 = new javax.swing.JLabel();
		classField = new javax.swing.JTextField();
		jLabel2 = new javax.swing.JLabel();
		superclassField = new javax.swing.JTextField();
		jLabel3 = new javax.swing.JLabel();
		packageField = new javax.swing.JTextField();
		jPanel1 = new javax.swing.JPanel();
		jScrollPane1 = new javax.swing.JScrollPane();
		methodList = new javax.swing.JList();
		addMethodInput = new javax.swing.JTextField();
		addMethodButton = new javax.swing.JButton();
		jPanel2 = new javax.swing.JPanel();
		jScrollPane2 = new javax.swing.JScrollPane();
		fieldList = new javax.swing.JList();
		addFieldInput = new javax.swing.JTextField();
		addFieldButton = new javax.swing.JButton();
		abstractCombo = new javax.swing.JComboBox();

		jLabel1.setText("public");

		classField.setBackground(new java.awt.Color(226, 244, 226));
		classField.setColumns(5);
		classField.addActionListener(new java.awt.event.ActionListener() {
			public void actionPerformed(java.awt.event.ActionEvent evt) {
				classFieldActionPerformed(evt);
			}
		});
		classField.addFocusListener(new java.awt.event.FocusAdapter() {
			@Override
			public void focusLost(java.awt.event.FocusEvent evt) {
				classFieldFocusLost(evt);
			}
		});

		jLabel2.setText("extends");

		superclassField.setBackground(new java.awt.Color(226, 244, 226));
		superclassField.setColumns(2);
		superclassField.addActionListener(new java.awt.event.ActionListener() {
			public void actionPerformed(java.awt.event.ActionEvent evt) {
				superclassFieldActionPerformed(evt);
			}
		});
		superclassField.addFocusListener(new java.awt.event.FocusAdapter() {
			@Override
			public void focusLost(java.awt.event.FocusEvent evt) {
				superclassFieldFocusLost(evt);
			}
		});

		jLabel3.setText("package ");

		packageField.setBackground(new java.awt.Color(226, 244, 226));
		packageField.addActionListener(new java.awt.event.ActionListener() {
			public void actionPerformed(java.awt.event.ActionEvent evt) {
				packageFieldActionPerformed(evt);
			}
		});
		packageField.addFocusListener(new java.awt.event.FocusAdapter() {
			@Override
			public void focusLost(java.awt.event.FocusEvent evt) {
				packageFieldFocusLost(evt);
			}
		});

		jPanel1.setBorder(javax.swing.BorderFactory.createTitledBorder(null,
				"Methods",
				javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION,
				javax.swing.border.TitledBorder.DEFAULT_POSITION,
				new java.awt.Font("Tahoma", 0, 11), new java.awt.Color(51, 51,
						51)));

		methodList.setBackground(new java.awt.Color(162, 201, 162));
		methodList.setComponentPopupMenu(getMethodPopupMenu());
		methodList.setModel(methodModel);
		jScrollPane1.setViewportView(methodList);

		addMethodInput.setBackground(new java.awt.Color(226, 244, 226));
		addMethodInput.addActionListener(new java.awt.event.ActionListener() {
			public void actionPerformed(java.awt.event.ActionEvent evt) {
				addMethodInputActionPerformed(evt);
			}
		});

		addMethodButton.setText("Add");
		addMethodButton.addActionListener(new java.awt.event.ActionListener() {
			public void actionPerformed(java.awt.event.ActionEvent evt) {
				addMethodButtonActionPerformed(evt);
			}
		});

		javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(
				jPanel1);
		jPanel1.setLayout(jPanel1Layout);
		jPanel1Layout.setHorizontalGroup(jPanel1Layout.createParallelGroup(
				javax.swing.GroupLayout.Alignment.LEADING).addGroup(
				javax.swing.GroupLayout.Alignment.TRAILING,
				jPanel1Layout.createSequentialGroup().addComponent(
						addMethodInput, javax.swing.GroupLayout.DEFAULT_SIZE,
						143, Short.MAX_VALUE).addPreferredGap(
						javax.swing.LayoutStyle.ComponentPlacement.RELATED)
						.addComponent(addMethodButton)).addComponent(
				jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 200,
				Short.MAX_VALUE));
		jPanel1Layout
				.setVerticalGroup(jPanel1Layout
						.createParallelGroup(
								javax.swing.GroupLayout.Alignment.LEADING)
						.addGroup(
								javax.swing.GroupLayout.Alignment.TRAILING,
								jPanel1Layout
										.createSequentialGroup()
										.addComponent(
												jScrollPane1,
												javax.swing.GroupLayout.DEFAULT_SIZE,
												125, Short.MAX_VALUE)
										.addPreferredGap(
												javax.swing.LayoutStyle.ComponentPlacement.RELATED)
										.addGroup(
												jPanel1Layout
														.createParallelGroup(
																javax.swing.GroupLayout.Alignment.BASELINE)
														.addComponent(
																addMethodButton)
														.addComponent(
																addMethodInput,
																javax.swing.GroupLayout.PREFERRED_SIZE,
																javax.swing.GroupLayout.DEFAULT_SIZE,
																javax.swing.GroupLayout.PREFERRED_SIZE))));

		jPanel2.setBorder(javax.swing.BorderFactory.createTitledBorder(null,
				"Fields",
				javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION,
				javax.swing.border.TitledBorder.DEFAULT_POSITION,
				new java.awt.Font("Tahoma", 0, 11), new java.awt.Color(51, 51,
						51)));

		fieldList.setBackground(new java.awt.Color(162, 201, 162));
		fieldList.setComponentPopupMenu(getFieldPopupMenu());
		fieldList.setModel(fieldModel);
		jScrollPane2.setViewportView(fieldList);

		addFieldInput.setBackground(new java.awt.Color(226, 244, 226));
		addFieldInput.addActionListener(new java.awt.event.ActionListener() {
			public void actionPerformed(java.awt.event.ActionEvent evt) {
				addFieldInputActionPerformed(evt);
			}
		});

		addFieldButton.setText("Add");
		addFieldButton.addActionListener(new java.awt.event.ActionListener() {
			public void actionPerformed(java.awt.event.ActionEvent evt) {
				addFieldButtonActionPerformed(evt);
			}
		});

		javax.swing.GroupLayout jPanel2Layout = new javax.swing.GroupLayout(
				jPanel2);
		jPanel2.setLayout(jPanel2Layout);
		jPanel2Layout.setHorizontalGroup(jPanel2Layout.createParallelGroup(
				javax.swing.GroupLayout.Alignment.LEADING).addGroup(
				javax.swing.GroupLayout.Alignment.TRAILING,
				jPanel2Layout.createSequentialGroup().addComponent(
						addFieldInput, javax.swing.GroupLayout.DEFAULT_SIZE,
						143, Short.MAX_VALUE).addPreferredGap(
						javax.swing.LayoutStyle.ComponentPlacement.RELATED)
						.addComponent(addFieldButton)).addComponent(
				jScrollPane2, javax.swing.GroupLayout.DEFAULT_SIZE, 200,
				Short.MAX_VALUE));
		jPanel2Layout
				.setVerticalGroup(jPanel2Layout
						.createParallelGroup(
								javax.swing.GroupLayout.Alignment.LEADING)
						.addGroup(
								javax.swing.GroupLayout.Alignment.TRAILING,
								jPanel2Layout
										.createSequentialGroup()
										.addComponent(
												jScrollPane2,
												javax.swing.GroupLayout.DEFAULT_SIZE,
												125, Short.MAX_VALUE)
										.addPreferredGap(
												javax.swing.LayoutStyle.ComponentPlacement.RELATED)
										.addGroup(
												jPanel2Layout
														.createParallelGroup(
																javax.swing.GroupLayout.Alignment.BASELINE)
														.addComponent(
																addFieldButton)
														.addComponent(
																addFieldInput,
																javax.swing.GroupLayout.PREFERRED_SIZE,
																javax.swing.GroupLayout.DEFAULT_SIZE,
																javax.swing.GroupLayout.PREFERRED_SIZE))));

		abstractCombo.setModel(new javax.swing.DefaultComboBoxModel(
				new String[] { "class", "abstract class" }));
		abstractCombo.addActionListener(new java.awt.event.ActionListener() {
			public void actionPerformed(java.awt.event.ActionEvent evt) {
				abstractComboActionPerformed(evt);
			}
		});

		javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
		this.setLayout(layout);
		layout
				.setHorizontalGroup(layout
						.createParallelGroup(
								javax.swing.GroupLayout.Alignment.LEADING)
						.addGroup(
								layout
										.createSequentialGroup()
										.addGroup(
												layout
														.createParallelGroup(
																javax.swing.GroupLayout.Alignment.LEADING)
														.addGroup(
																layout
																		.createSequentialGroup()
																		.addComponent(
																				jLabel3)
																		.addPreferredGap(
																				javax.swing.LayoutStyle.ComponentPlacement.RELATED)
																		.addComponent(
																				packageField,
																				javax.swing.GroupLayout.DEFAULT_SIZE,
																				159,
																				Short.MAX_VALUE))
														.addGroup(
																layout
																		.createSequentialGroup()
																		.addComponent(
																				jLabel1)
																		.addPreferredGap(
																				javax.swing.LayoutStyle.ComponentPlacement.RELATED)
																		.addComponent(
																				abstractCombo,
																				javax.swing.GroupLayout.PREFERRED_SIZE,
																				67,
																				javax.swing.GroupLayout.PREFERRED_SIZE)
																		.addPreferredGap(
																				javax.swing.LayoutStyle.ComponentPlacement.RELATED)
																		.addComponent(
																				classField,
																				javax.swing.GroupLayout.DEFAULT_SIZE,
																				102,
																				Short.MAX_VALUE))
														.addGroup(
																layout
																		.createSequentialGroup()
																		.addComponent(
																				jLabel2)
																		.addPreferredGap(
																				javax.swing.LayoutStyle.ComponentPlacement.RELATED)
																		.addComponent(
																				superclassField,
																				javax.swing.GroupLayout.DEFAULT_SIZE,
																				163,
																				Short.MAX_VALUE)))
										.addContainerGap()).addComponent(
								jPanel2, javax.swing.GroupLayout.DEFAULT_SIZE,
								javax.swing.GroupLayout.DEFAULT_SIZE,
								Short.MAX_VALUE).addComponent(jPanel1,
								javax.swing.GroupLayout.DEFAULT_SIZE,
								javax.swing.GroupLayout.DEFAULT_SIZE,
								Short.MAX_VALUE));
		layout
				.setVerticalGroup(layout
						.createParallelGroup(
								javax.swing.GroupLayout.Alignment.LEADING)
						.addGroup(
								layout
										.createSequentialGroup()
										.addGroup(
												layout
														.createParallelGroup(
																javax.swing.GroupLayout.Alignment.BASELINE)
														.addComponent(jLabel3)
														.addComponent(
																packageField,
																javax.swing.GroupLayout.PREFERRED_SIZE,
																javax.swing.GroupLayout.DEFAULT_SIZE,
																javax.swing.GroupLayout.PREFERRED_SIZE))
										.addPreferredGap(
												javax.swing.LayoutStyle.ComponentPlacement.RELATED)
										.addGroup(
												layout
														.createParallelGroup(
																javax.swing.GroupLayout.Alignment.BASELINE)
														.addComponent(jLabel1)
														.addComponent(
																abstractCombo,
																javax.swing.GroupLayout.PREFERRED_SIZE,
																javax.swing.GroupLayout.DEFAULT_SIZE,
																javax.swing.GroupLayout.PREFERRED_SIZE)
														.addComponent(
																classField,
																javax.swing.GroupLayout.PREFERRED_SIZE,
																javax.swing.GroupLayout.DEFAULT_SIZE,
																javax.swing.GroupLayout.PREFERRED_SIZE))
										.addPreferredGap(
												javax.swing.LayoutStyle.ComponentPlacement.RELATED)
										.addGroup(
												layout
														.createParallelGroup(
																javax.swing.GroupLayout.Alignment.BASELINE)
														.addComponent(jLabel2)
														.addComponent(
																superclassField,
																javax.swing.GroupLayout.PREFERRED_SIZE,
																javax.swing.GroupLayout.DEFAULT_SIZE,
																javax.swing.GroupLayout.PREFERRED_SIZE))
										.addPreferredGap(
												javax.swing.LayoutStyle.ComponentPlacement.RELATED)
										.addComponent(
												jPanel2,
												javax.swing.GroupLayout.DEFAULT_SIZE,
												javax.swing.GroupLayout.DEFAULT_SIZE,
												Short.MAX_VALUE)
										.addPreferredGap(
												javax.swing.LayoutStyle.ComponentPlacement.RELATED)
										.addComponent(
												jPanel1,
												javax.swing.GroupLayout.DEFAULT_SIZE,
												javax.swing.GroupLayout.DEFAULT_SIZE,
												Short.MAX_VALUE)
										.addContainerGap()));
	}// </editor-fold>

	private void packageFieldFocusLost(java.awt.event.FocusEvent evt) {
		if (packageField.getText().length() > 0)
			updatePackage(packageField.getText());
	}

	private void classFieldFocusLost(java.awt.event.FocusEvent evt) {
		if (classField.getText().length() > 0)
			updateClassName(classField.getText());
	}

	private void superclassFieldFocusLost(java.awt.event.FocusEvent evt) {
		if (superclassField.getText().length() > 0)
			updateParent(superclassField.getText());
	}

	private void packageFieldActionPerformed(java.awt.event.ActionEvent evt) {
		if (packageField.getText().length() > 0)
			updatePackage(packageField.getText());
	}

	private void classFieldActionPerformed(java.awt.event.ActionEvent evt) {
		if (classField.getText().length() > 0)
			updateClassName(classField.getText());
	}

	private void superclassFieldActionPerformed(java.awt.event.ActionEvent evt) {
		if (superclassField.getText().length() > 0)
			updateParent(superclassField.getText());
	}

	private void addMethodButtonActionPerformed(java.awt.event.ActionEvent evt) {
		String txt = addMethodInput.getText();
		if (txt.length() > 0) {
			addMethodInput.setText(null);
			addMethod(txt);
		}
	}

	private void addMethodInputActionPerformed(java.awt.event.ActionEvent evt) {
		String txt = addMethodInput.getText();
		if (txt.length() > 0) {
			addMethodInput.setText(null);
			addMethod(txt);
		}
	}

	private void addFieldInputActionPerformed(java.awt.event.ActionEvent evt) {
		String txt = addFieldInput.getText();
		if (txt.length() > 0) {
			addFieldInput.setText(null);
			addField(txt);
		}
	}

	private void addFieldButtonActionPerformed(java.awt.event.ActionEvent evt) {
		String txt = addFieldInput.getText();
		if (txt.length() > 0) {
			addFieldInput.setText(null);
			addField(txt);
		}
	}

	private void abstractComboActionPerformed(java.awt.event.ActionEvent evt) {
		boolean ab = abstractCombo.getSelectedIndex() == 1;
		setAbstract(ab);
	}

	// Variables declaration - do not modify
	protected javax.swing.JComboBox abstractCombo;
	protected javax.swing.JButton addFieldButton;
	protected javax.swing.JTextField addFieldInput;
	protected javax.swing.JButton addMethodButton;
	protected javax.swing.JTextField addMethodInput;
	protected javax.swing.JTextField classField;
	protected javax.swing.JList fieldList;
	protected javax.swing.JLabel jLabel1;
	protected javax.swing.JLabel jLabel2;
	protected javax.swing.JLabel jLabel3;
	protected javax.swing.JPanel jPanel1;
	protected javax.swing.JPanel jPanel2;
	protected javax.swing.JScrollPane jScrollPane1;
	protected javax.swing.JScrollPane jScrollPane2;
	protected javax.swing.JList methodList;
	protected javax.swing.JTextField packageField;
	protected javax.swing.JTextField superclassField;
	// End of variables declaration

}
